import java.util.Scanner;

public class J103102 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int len = in.nextInt();
        int times = in.nextInt();
        int[] nums = new int[len];
        for (int j = 0; j < len; j++) {
            nums[j] = in.nextInt();
        }
        for (int m = 0; m < times; m++) {
            int sum = 0;
            int i = in.nextInt() - 1;
            int k = in.nextInt();
            for (; i < k; i++) {
                sum += nums[i];
            }
            System.out.println(sum);
        }
    }
}
